package tests

import org.scalatest.FlatSpec
import org.scalatest.Matchers
import tp1._

class TestAgregar extends FlatSpec with Matchers  {

   "reserva1" should "agregar reserva en el rango de 10 a 18" in {
   val cancha1 = new Cancha(new CanchaFutbol(10))
   val reserva1 = new Reserva(cancha1,3,2,12,14) with CanchaConTribuna
   cancha1.puedeAgregarReserva(reserva1)
   cancha1.cantidadDeReservas should equal(1)
   }
   
   "reserva2" should "agregar reserva fuera del rango de 10 a 18" in {
    a[Throwable] should be thrownBy {
   val cancha2 = new Cancha(new CanchaTennis)
   val reserva2 = new Reserva(cancha2,3,2,18,19) with CanchaConTribuna
   cancha2.puedeAgregarReserva(reserva2)
   }
   }
    
   "reserva3" should "agregar reserva fuera del rango de 10 a 18 pero con cancha con luz" in {
   val cancha3 = new Cancha(new CanchaTennis)
   val reserva3 = new Reserva(cancha3,3,2,18,19) with CanchaConTribuna with CanchaConLuz
   cancha3.puedeAgregarReserva(reserva3)
   cancha3.cantidadDeReservas should equal(1)
   } 
   
   "reservas1" should "agregar reservas con fechas y hora no repetida" in {
   val cancha3 = new Cancha(new CanchaTennis)
   val reservaA = new Reserva(cancha3,3,2,18,19) with CanchaConTribuna with CanchaConLuz
   val reservaB = new Reserva(cancha3,3,3,14,15) with CanchaConTribuna 
   val reservaC = new Reserva(cancha3,3,4,14,15) with CanchaConTribuna with CanchaConTecho
   val SMet = new ServicioMeteorologico(true)
   reservaC.clima=SMet.llueve
   val reservaD = new Reserva(cancha3,3,6,19,20) with CanchaConLuz
   cancha3.puedeAgregarReserva(reservaA)
   cancha3.puedeAgregarReserva(reservaB)
   cancha3.puedeAgregarReserva(reservaC)
   cancha3.puedeAgregarReserva(reservaD)
   cancha3.cantidadDeReservas should equal(4)
   } 
   
   "reservas2" should "agregar reservas con misma fecha y horarios repetidos" in {
   a[Throwable] should be thrownBy {
   val cancha3 = new Cancha(new CanchaTennis)
   val reservaA = new Reserva(cancha3,3,2,18,19) with CanchaConTribuna with CanchaConLuz
   val reservaB = new Reserva(cancha3,3,4,14,15) with CanchaConTribuna 
   val reservaC = new Reserva(cancha3,3,4,14,15) with CanchaConTribuna with CanchaConTecho
   val SMet = new ServicioMeteorologico(true)
   reservaC.clima=SMet.llueve
   cancha3.puedeAgregarReserva(reservaA)
   cancha3.puedeAgregarReserva(reservaB)
   cancha3.puedeAgregarReserva(reservaC)
   }
   } 
   

}